/*
 * @Author: wuqingchun
 * @Date: 2024-10-15 20:00:01
 * @Description: 
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-10-15 20:01:34
 */
#ifndef __REDIS_MSG_H__
#define __REDIS_MSG_H__

// 消息类型枚举定义
typedef enum tagNMonMsgType
{
	NMON_MSG_CONNECTED                    = 0,    //连接建立成功
	NMON_MSG_DISCONNECTED                 = 1,    //连接断开
	NMON_MSG_AUTH_SUCCESS                 = 2,    //认证成功
	NMON_MSG_LOGIN_SUCCESS                = 3,    //登录成功
	NMON_MSG_SEAT_QUERY_RSP               = 4,    //查询席位应答
	NMON_MSG_SEAT_QUERY_RSP_LAST          = 5,    //查询席位最后一笔应答
	NMON_MSG_INSTRUMENT_QUERY_RSP         = 6,    //查询合约应答
	NMON_MSG_INSTRUMENT_QUERY_RSP_LAST    = 7,    //查询合约最后一笔应答
	NMON_MSG_ORDER_VOLUME_QUERY_RSP       = 8,    //查询合约报单数量应答
	NMON_MSG_ORDER_VOLUME_QUERY_RSP_LAST  = 9,    //查询合约报单数量最后一笔应答
	NMON_MSG_ORDER_RTN                    = 10,   //回报主推
	NMON_MSG_EXCHANGE_STATUS_RTN          = 11,   //交易所状态主推
	NMON_MSG_PRODUCT_STATUS_RTN           = 12,   //品种状态主推
	NMON_MSG_MARKET_DATA_QUERY_RSP        = 13,   //行情查询应答
	NMON_MSG_FPGA_MD_NOTIFY               = 14,   //FPGA行情通知
	NMON_MSG_TIMER                        = 15,   //定时器消息
	NMON_MSG_STOP_SERVICE                 = 16,   //停止服务
	NMON_MSG_MAX,
}REDIS_MSG_TYPE_E;

struct CRedisMessage
{
	REDIS_MSG_TYPE_E enType;
	void *pData;
	CRedisMessage ()
	{
		enType = NMON_MSG_MAX;
		pData = nullptr;
	}

	CRedisMessage (REDIS_MSG_TYPE_E enType, void *pData)
	{
		this->enType = enType;
		this->pData = pData;
	}

	const char* TypeToString()
	{
		static const char *apcStr[NMON_MSG_MAX] =
		{
			"MSG_CONNECTED",
			"MSG_DISCONNECTED",
			"MSG_AUTH_SUCCESS",
			"MSG_LOGIN_SUCCESS",
			"MSG_SEAT_QUERY_RSP",
			"MSG_SEAT_QUERY_RSP_LAST",
			"MSG_INSTRUMENT_QUERY_RSP",
			"MSG_INSTRUMENT_QUERY_RSP_LAST",
			"MSG_ORDER_VOLUME_QUERY_RSP",
			"MSG_ORDER_VOLUME_QUERY_RSP_LAST",
			"MSG_ORDER_RTN",
			"MSG_EXCHANGE_STATUS_RTN",
			"MSG_PRODUCT_STATUS_RTN",
			"MSG_MARKET_DATA_QUERY_RSP",
			"MSG_FPGA_MD_NOTIFY",
			"MSG_TIMER",
			"MSG_STOP_SERVICE",
		};

		if (NMON_MSG_CONNECTED <= enType && enType < NMON_MSG_MAX)
		{
			return apcStr[enType];
		}

		return "MSG_UNKNOWN";
	}
};

#endif //__REDIS_MSG_H__
